<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>考勤</title>
    
    <link href="../../css/mui.min.css" rel="stylesheet"/>
    <link href="../../css/style.css" rel="stylesheet"/>
    <link href="../../css/iconfont.css" rel="stylesheet"/>
    <script src="../../js/mui.min.js"></script>
    <script src="../../libs/bower_components/angular/angular.min.js"></script>
    <script src="../../libs/bower_components/angular-resource/angular-resource.min.js"></script>
	<script src="../../js/app.js"></script>
</head>
<body ng-app="attendance" ng-controller="ctrl_self">
<style type="text/css">
	.mui-table-view {
		margin-bottom: 20px;
	}
</style>
<div id="grid-href">
<ul class="mui-table-view mui-table-view-chevron">
	<li class="mui-table-view-cell mui-media">
		<a class="mui-navigate-right" href="setting.html" content="个人">
			<img class="mui-media-object mui-pull-left head-img" id="head-img" src="../../images/user-photo.png">
			<div class="mui-media-body">
				<span ng-model="name">{{name}}</span>
				<p class='mui-ellipsis'>{{phone}}</p>
			</div>
		</a>
	</li>
</ul>
<ul class="mui-table-view mui-grid-view mui-grid-9" style="background-color: #fff;">
    <li class="mui-table-view-cell mui-media mui-col-xs-6 mui-col-sm-6"><a href="edit-attendance.html" content="新建请假">
            <span class="mui-icon mui-icon-compose"></span>
            <div class="mui-media-body">新建请假</div></a></li>
    <li class="mui-table-view-cell mui-media mui-col-xs-6 mui-col-sm-6"><a href="sign.html" content="签到查询">
        	<span class="mui-icon mui-icon-search"></span>
        	<div class="mui-media-body">签到查询</div></a></li>
    <li class="mui-table-view-cell mui-media mui-col-xs-6 mui-col-sm-6"><a href="chat.html" content="摇一摇">
            <span class="mui-icon mui-icon-paperplane"></span>
            <div class="mui-media-body">摇一摇</div></a></li>
    <li class="mui-table-view-cell mui-media mui-col-xs-6 mui-col-sm-6"><a href="feedback.html" content="帮助与反馈">
            <span class="mui-icon mui-icon-email"></span>
            <div class="mui-media-body">帮助与反馈</div></a>
    </li>
</ul>
<br>
<ul class="mui-table-view mui-table-view-chevron">
	<li class="mui-table-view-cell">
		<a href="../statistic/statistic-self.html" class="mui-navigate-right" content="我发起的">我发起的</a>
	</li>
	<li class="mui-table-view-cell not-worker">
		<a href="../statistic/statistic-self.html" class="mui-navigate-right" content="我处理的">我处理的</a>
	</li>
</ul>
</div>
<ul class="mui-table-view" id="quit">
	<li class="mui-table-view-cell" style="text-align: center;">
		<a>退出登录</a>
	</li>
</ul>
<script type="text/javascript">
	var list = document.querySelectorAll('.not-worker');
	var storage = window.localStorage;
	if (storage.getItem("position") == "0" && list) {
		for (var i = 0; i < list.length; i++) {
			list[i].style.display = 'none';
		}
	}
	
	mui('#grid-href').on('tap', 'a', function(e) {
		mui('#dash').each(function(){
			this.style.display = 'none';
		});
		
		var targetTab = this.getAttribute('href');
		var title = this.getAttribute('content');
		mui.openWindow({
		    url:targetTab,
		    id:targetTab,
		    extras:{
		        title:title
		    }
		});
	});
	
	var root = storage.getItem("root");
	document.getElementById('quit').addEventListener('tap', function() {
		storage.clear();
		storage.setItem("root", root);
		mui.ajax(root+'/user/logout', {
			dataType:'json',//服务器返回json格式数据
			type:'get',//HTTP请求类型
			timeout:0,//超时时间设置为5秒；
			success:function(data){
				//服务器返回响应，根据响应结果，分析是否登录成功；
				if(data.status == 'OK'){
					mui.toast('注销成功');
					var curr = plus.webview.currentWebview(); 
					var wvs = plus.webview.all(); 
		
					for(var i = 0, len = wvs.length; i < len; i++) { //关闭除setting页面外的其他页面
						if(wvs[i].getURL() == curr.getURL()) 
							continue; 
						plus.webview.close(wvs[i]); 
					} //打开login页面后再关闭setting页面
					plus.webview.open('../login.html'); 
//					mui.openWindow({
//					    url:'../login.html',
//					    id:'login.html'
//					});
					curr.close();
				}else{
					mui.toast('注销错误');
				}
			},
			error:function(xhr,type,errorThrown){
				//异常处理；
				console.log(xhr,type,errorThrown);
				mui.toast('网络异常');
			}
		});
	});
</script>
</body>
</html>